<style>
.send-error {opacity:0.8;border:1px solid #e74c3c;}
.send-success {opacity:0.8;border:1px solid #18bc9c;}
.previewBroad .title , .previewBroad .submsg-title {
    padding: 0px 0px;
}
.submsg-title p{line-height:1.5em;}
.previewBroad {    padding: 5px 10px;}
.previewBroad p{border-bottom:1px solid #e7e7eb;}
.previewBroad .appmsg{border:0 none;}
</style>

		<div class="ui-portlet">
			{{template wxes/_user_wxes}}
			<ol class="breadcrumb">
			  <li><a href="/users/index"><i class="fa fa-home"></i>&nbsp;&nbsp;个人中心</a></li>
			  <li class="active">定时群发列表</li>
			</ol>
		</div>
       <hr>
       <div class="mb10">
       	<a class="btn btn-primary" href="{{$this->Html->url(array('action'=>'add'))}}"><i class="fa fa-plus"></i> 新增群发</a>
		   <a class="btn btn-primary" href="http://www.135plat.com/wxes/pauth"><i class="fa fa-weixin"></i> 授权新公众号</a>
       </div>
		<p>PS:将群发时间设置1~2分钟后，相当于刚加入后一会就马上群发。手机在路上也可操作进行群发哦。</p>
      
       <div class="alert alert-warning"><p><strong>提示：</strong></p>
       		<ul>
       			<li>定时群发只支持已授权且微信认证的公众号</li>
       			<li>设置成一个未来的时间点，系统将在指定的时间开始发送消息。</li>
       			<li>当很多人定时在同一时间点时，将按先后发送，时间可能会出现延迟</li>
       			<li>定时群发使用微信公众号接口，暂不支持原创标记与评论。</li>
       		</ul>
       </div>
              
       <div class="ui-portlet">
	       <div class="row clearfix ui-portlet-list" id="storefront-list">
	       {{loop $datalist $item}}
	       	<div class="col-md-4 mix">
	       		<div class="appmsg {{if $item['WxTimingBroad']['status'] == 2 || ($item['WxTimingBroad']['status'] == 0 && $item['WxTimingBroad']['sendtime'] < date('Y-m-d H:i:s',time()-600))}} send-error{{elseif $item['WxTimingBroad']['status'] == 1 }}send-success{{/if}}">
		       		<div class="appmsg_content">
		       		<p>
		       		{{if $item['WxTimingBroad']['msg_type'] == 'news'}} 
		       			群发图文
		       		{{elseif $item['WxTimingBroad']['msg_type'] == 'voice'}} 
		       			群发语音
		       		{{elseif $item['WxTimingBroad']['msg_type'] == 'video'}} 
		       			群发视频
		       		{{elseif $item['WxTimingBroad']['msg_type'] == 'image'}} 
		       			群发图片
		       		{{/if}}
		       		</p>
		       		
		       		{{if $item['WxTimingBroad']['status'] == 2}}
		       		 	<p class="alert alert-danger">
		       		 		{{if strpos($item['WxTimingBroad']['failedmsg'],'48001') !== false }}
		       		 			公众号未微信认证，无群发接口权限
		       		 		{{elseif strpos($item['WxTimingBroad']['failedmsg'],'48003') !== false }}
		       		 			没有同意开通群发功能，请到微信后台查看
		       		 		{{elseif strpos($item['WxTimingBroad']['failedmsg'],'45028') !== false }}
		       		 			今天已经群发过消息，没有配额了。
		       		 		{{else}}
								{{$item['WxTimingBroad']['failedmsg']}}
							{{/if}}
		       		 	
		       		 	
		       		 	</p>
		       		 {{elseif $item['WxTimingBroad']['status'] == 1 }}
		       		 	<p class="alert alert-success">发送成功</p>	
		       		 {{elseif $item['WxTimingBroad']['status'] == 0 }}
		       		 	{{if $item['WxTimingBroad']['sendtime'] < date('Y-m-d H:i:s',time()-600)}}
		       		 		<p class="alert alert-danger">过期未发送</p>
		       		 	{{else}}
		       		 		<p class="alert alert-warning">未发送</p>	
		       		 	{{/if}}	       		 
		       		 {{/if}}
		       		
		       		
		       		<!-- <p>素材编号：{{$item['WxTimingBroad']['media_id']}}</p> -->
		       		
		       		<p>群发时间:<br/>{{substr($item['WxTimingBroad']['sendtime'],0,16)}}</p>
		       		</div>
		       		
		       		<div class="previewBroad" data-editable="{{if $item['WxTimingBroad']['status'] == 0 && $item['WxTimingBroad']['sendtime'] > date('Y-m-d H:i:s',time()-600)}}1{{else}}0{{/if}}" data-mid="{{$item['WxTimingBroad']['media_id']}}">
		       			<a href="javascript:void(0)">查看</a>
		       		</div>
		       		
		       		<div class="appmsg_opr clearfix">
		       			{{$this->Html->link('<i data-toggle="tooltip" data-placement="top" title="'.__('Edit').'" class="fa fa-edit"></i>', array('controller'=>'wx_timing_broads','action' => 'edit', $item['WxTimingBroad']['id']),array('class'=>'col-xs-6 opr-edit','escape'=>false))}}
		       			
		       			
		       			<a href="javascript:void(0)" data-url="{{$this->Html->url('/wx_timing_broads/delete/'.$item['WxTimingBroad']['id'])}}" class="col-xs-6 delete-pop" data-content="确定删除此素材？"><i data-toggle="tooltip" data-placement="top" 
		       			 title="{{__('Delete')}}" class="fa fa-trash"></i></a>
		       			 
		       			 <!-- {{$this->Html->link('', array('controller'=>'wx_msgs','action' => 'delete', $item['WxTimingBroad']['id']),array('class'=>'col-xs-6','escape'=>false))}}
		       			  -->
		       		</div>
	       		</div>
	       	</div>
	  		{{/loop}}
	    	</div>
	    	<div>{{$page_navi}}</div>
    	</div>
<script>
$(function(){
	$('.previewBroad').click(function(){
		var mid = $(this).data('mid');
		$(this).load('/wx_msgs/wechat_preview?media_id='+mid+' #wxmsg-preview',function(){
			if( $(this).data('editable') == 1 ){ //未发送的允许编辑
				$(this).find('a').each(function(i){$(this).before('<a target="_blank" href="http://www.135editor.com?mid='+mid+'&idx='+i+'" style="float:left;"><i class="fa fa-edit"></i></a>&nbsp;&nbsp; ')});
			}
		});
		$(this).unbind('click');
	});
	$('.previewBroad').each(function(i){
		if(i<9){
			$(this).trigger('click');
		}
	})
})

</script>